package com.ecnu.jiagou.damai.service;

import java.util.List;

import com.ecnu.jiagou.damai.entity.Address;
import com.ecnu.jiagou.damai.entity.Person;
import com.ecnu.jiagou.damai.mapper.ManageMapper;
import com.ecnu.jiagou.damai.result.Result;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ManageService {
    
    @Autowired
    private ManageMapper manageMapper;

    public Result<List<Address>> getAddress(Integer userid){
        List<Address> list = manageMapper.getAddress(userid);
        return Result.success(list);
    }

    public Result<Boolean> addAddress(Address address){
        boolean flag = manageMapper.addAddress(address);
        return Result.success(flag);
    }

    public Result<Boolean> updateAddress(Address address){
        boolean flag = manageMapper.updateAddress(address);
        return Result.success(flag);
    }

    public Result<Boolean> deleteAddress(Integer addressid){
        boolean flag = manageMapper.deleteAddress(addressid);
        return Result.success(flag);
    }

    public Address getAddressById(Integer addressid){
        return manageMapper.getAddressById(addressid);
    }

    public List<Person> getPersonList(Integer userid){
        return manageMapper.getPerson(userid);
    }

    public Boolean addPerson(Person person){
        return manageMapper.addPerson(person);
    }

    public Boolean deletePerson(Integer personid){
        return manageMapper.deletePerson(personid);
    }
}
